package com.juneng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.Condition;
import com.juneng.utils.BeanCopyUtils;
import com.juneng.entity.CommentReply;
import com.juneng.mapper.CommentReplyMapper;
import com.juneng.service.ICommentReplyService;
import com.juneng.dto.CommentReplyDto;
import com.juneng.dto.CommentReplyQueryDto;
import com.juneng.vo.CommentReplyVo;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import java.util.List;
/**
 *  服务实现类
 *
 * @author zds
 * @since 2021-07-29
 */
@Service
@AllArgsConstructor
public class CommentReplyServiceImpl implements ICommentReplyService {

    protected CommentReplyMapper commentReplyMapper;
    @Override
    public IPage<CommentReplyVo> page(CommentReplyQueryDto dto) {
        IPage<CommentReplyVo> page = Condition.getPage(dto);
        return commentReplyMapper.page(page,dto);
    }

    @Override
    public List<CommentReply> list(CommentReplyQueryDto dto) {
        QueryWrapper<CommentReply> queryWrapper = new QueryWrapper<>(BeanCopyUtils.copy(dto,CommentReply.class));
        return commentReplyMapper.selectList(queryWrapper);
    }

    @Override
    public Integer save(CommentReplyDto dto) {
        return commentReplyMapper.insert(BeanCopyUtils.copy(dto,CommentReply.class));
    }

    @Override
    public Integer updateById(CommentReplyDto dto) {
        return commentReplyMapper.updateById(BeanCopyUtils.copy(dto,CommentReply.class));
    }

    @Override
    public Integer deleteLogic(Long id) {
        return commentReplyMapper.deleteById(id);
    }

    @Override
    public CommentReply getById(Long id) {
        return commentReplyMapper.selectById(id);
    }
}
